package com.example.shixunandjavagotoyangchen.BoosYang.Day003.Day003_FX2;

import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.example.modelviewpresenter.View.BasterFragment;
import com.example.shixunandjavagotoyangchen.R;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

import java.util.List;


public class BlankFragmentCommunity2 extends BasterFragment {

    private RecyclerView naalcView;

    @Override
    public int BandLayout() {
        return R.layout.fragment_blank_fragment_community2;
    }

    @Override
    public void initView() {

        naalcView = (RecyclerView) findViewById(R.id.naalc_view);
        naalcView.setLayoutManager(new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL));
    }

    @Override
    public void initDate() {
        OkGo.<String>get("http://10.161.52.10/yoho/home_shequtwo.php").execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {
                Gson gson = new Gson();
                NAALC naalc = gson.fromJson(response.body().toString(), NAALC.class);
                List<NAALC.ShequBean> shequBeans = naalc.getShequ();
                NAALCadpter aadpter = new NAALCadpter(shequBeans);
                naalcView.setAdapter(aadpter);
            }
        });
    }
}
